<template>
  <div class="chart-box">
    <Line class="chart" :loading="loadingRef" :chartData="chartData" title="本周期数据" />
  </div>
</template>
<script lang="ts"
  setup>
  import { ref, } from 'vue'
  import { getQoqData } from '@/api/dataReport/energyStatistics'
  import Line from '@/components/Charts/Line/index.vue'
  import { cloneDeep } from 'lodash-es'

  const emptyData = {
    xaxisList: [],
    yaxisList: [],
  }

  const chartData = ref(cloneDeep(emptyData))
  const loadingRef = ref(false)

  const getData = (searchInfo) => {
    loadingRef.value = true
    // 数据环比
    getQoqData(searchInfo)
      .then((e) => {
        chartData.value = e
      }).catch(() => {
        chartData.value = cloneDeep(emptyData)

      }).finally(() => {
        loadingRef.value = false
      })
  }

  defineExpose({
    getData,
  })
</script>
